package cn.weiyan.dtx.tccdemo.bank1.controller;

import cn.weiyan.dtx.tccdemo.bank1.server.AccountInfoServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author misterWei
 * @create 2020年02月14号:18点18分
 * @mailbox mynameisweiyan@gmail.com
 */
@RestController
public class Bank1Controller {
    @Autowired
    AccountInfoServer accountInfoService;
    //转账
    @GetMapping("/transfer")
    public String transfer(Double amount)
    {
        // 测试controller 自定义处理异常是否全局事务生效
        try {
            accountInfoService.updateAccountBalance("1",amount);
        }catch (Exception e){
            return e.getMessage();
        }

    return "bank1"+amount;
    }
}
